capture log close
log using "Y:\Documents\Output\variables", replace text

*************************************************************   
* do-file to create individual level variables from NEPS 	*
* 	create major level variables from NEPS			 		*
* 	merge into integrated dataset for analysis				*
*	fo 02.07.2015											*
*************************************************************

version 13
clear
set more off

* replace location of neps data *
local dirneps = "Z:\SUF\Remote\SC5\SC5_R_4-0-0\Stata\"

*******************************
*** major level variables	***
*******************************

/*** results matrix
	1 - major id
	2 - major size
	3 - math intensity (mean)
	4 - math intensity (se)
	5 - diff: approval from parents (for women) - "" (for men)
	6 - diff: approval from peers (for women) - "" (for men)
	7 - women: approval from parents (mean)
	8 - women: approval from parents (se)
	9 - men: approval from parents (mean)
	10 - men: approval from parents (se)
	11 - female (mean)
	12 - female (se)
	13 - women: approval from peers (mean)
	14 - women: approval from peers (se)
	15 - men: approval from peers (mean)
	16 - men: approval from peers (se)
	17 - diff: approval from parents (se)
	18 - diff: approval from peers (se)
	19 - care major (0/1)
***/

*** compute approval rates and proportion female from neps ***
**************************************************************

*** merge data with weights ***
	* CATI - pTarget (Welle 1)
	use "`dirneps'SC5_pTargetCATI_R_4-0-0.dta", clear
	keep ID_t-inty tg04001_g1R tg04004_g1R t700001 t70000y t30240a tg15003 tg15004 tg02001
	keep if wave==1
	save "Data\data_fach_w1.dta", replace

	* weights (f�r Wellen 1)
	use "`dirneps'SC5_Weights_R_4-0-0.dta", clear
	keep ID_t w_t1_std
	merge 1:1 ID_t using "Data\data_fach_w1.dta"
	drop _merge

	* homogenize variable name with his data
	recode tg04001_g1R(-97=.), gen(B1ber1ab1)
	recode tg04004_g1R(-97 -95 -93 -54=.), gen(B1ber2ab1)

* identify students on teacher track
gen lehramt=.
replace lehramt=1 if tg02001==1 | tg02001==2
replace lehramt=0 if tg02001==3 | tg02001==4| tg02001==5| tg02001==6| tg02001==7| tg02001==8
replace B1ber1ab1=80 if lehramt==1 

* merge small but similar majors
	* cath. theology --> prot. theology
	recode B1ber1ab1(3=2)
	* philosophy --> history
	recode B1ber1ab1(4=5)
	* non-german philologies and cultural sciences --> cultural sciences
	recode B1ber1ab1(1 7 8 9 10 11 12 13=14)
	* special needs pedagogy --> pegagogy
	recode B1ber1ab1(17=16)
	* social and economic studies, political science --> social sciences
	recode B1ber1ab1(23 25=26)
	* mining and metallurgy --> geosciences
	recode B1ber1ab1(62=43)
	* urban and regional planning --> geography
	recode B1ber1ab1(67 57=44)
	* dentistry --> medical science
	recode B1ber1ab1(50=49)
	* forestry --> agronomy
	recode B1ber1ab1(59=58)
	* design --> architecture and interior design
	recode B1ber1ab1(76=66)
	* surveying and mapping, traffic engineering --> civil engineering
	recode B1ber1ab1 (65 69=68)
	* fine arts, performing arts, music, musicology --> art, art history
	recode B1ber1ab1(75 77 78=74)
	* industrial engineering(ing) --> industrial engineering(bwl)
	recode B1ber1ab1(70=31)
	label value B1ber1ab1 de2543ext1

*** define sample ***
gen sample=1
gen alter= 2011-t70000y
replace sample=0 if alter>25		/* drop if respondent older than 25yrs when starting degree */
recode t700001 (-97=.)(1=0)(2=1), gen(frau)
replace sample=0 if frau==.
keep if sample==1

* only fields with at least 100 observations in the 2nd wave (below) 
gen fsamp=0
foreach num of numlist 5 14 15 16 26 27 28 30 31 37 38 39 40 42 44 49 58 63 64 66 68 74 80 {
	replace fsamp=1 if B1ber1ab1==`num' 
	}
keep if fsamp==1
drop fsamp

* results matrix
qui tab B1ber1ab1, gen(fachdum)
global fachnr = r(r)
lab val fachdum1-fachdum$fachnr de2543ext1
matrix fneps = J($fachnr, 19, .)

recode tg15003 (-98 -97=.)(1 2 3=0)(4 5=1), gen(eltap) 
recode tg15004 (-98 -97 -52=.)(1 2 3=0)(4 5=1), gen(peerap)
replace sample=0 if (eltap==. | peerap==.)
svyset ID_t[pw=w_t1_std]

* plug estimates into results matrix
qui forvalues i = 1/$fachnr {
	summarize B1ber1ab1 if (fachdum`i'==1)
		matrix fneps [`i', 1] = r(mean)
	svy: mean eltap if (fachdum`i'==1 & frau==1)
		matrix fneps [`i', 7] = _b[eltap]
		matrix fneps [`i', 8] = _se[eltap]
	svy: mean eltap if (fachdum`i'==1 & frau==0)
		matrix fneps [`i', 9] = _b[eltap]
		matrix fneps [`i', 10] = _se[eltap] 
	matrix fneps [`i', 5]  = (fneps[`i', 7] - fneps[`i', 9])	/* >0 if women get more approval than men */
	svy: mean eltap if (fachdum`i'==1), over(frau)
	lincom [eltap]1 - [eltap]0
		matrix fneps [`i', 17] = r(se)
	svy: mean peerap if (fachdum`i'==1 & frau==1)
		matrix fneps [`i', 13] = _b[peerap]
		matrix fneps [`i', 14] = _se[peerap]
	svy: mean peerap if (fachdum`i'==1 & frau==0)
		matrix fneps [`i', 15] = _b[peerap]
		matrix fneps [`i', 16] = _se[peerap]
	matrix fneps [`i', 6] = (fneps[`i', 13] - fneps[`i', 15])	 /* >0 if women get more approval than men */
	svy: mean peerap if (fachdum`i'==1), over(frau)
	lincom [peerap]1 - [peerap]0
		matrix fneps [`i', 18] = r(se)
	svy: mean frau if (fachdum`i'==1)
		matrix fneps [`i',11] = _b[frau]
		matrix fneps [`i',12] = _se[frau]
	}
matrix list fneps
	
*** mathint (item from wave2, therefore computed from smaller sample) ***
*************************************************************************

*** create dataset from multiple panel waves 
* CATI - pTarget (Welle 1)
	use "`dirneps'SC5_pTargetCATI_R_4-0-0.dta", clear
	keep ID_t-inty tg04001_g1R tg04004_g1R t700001 t70000y t30240a tg15003 tg15004 tg02001
	keep if wave==1
	save "Data\data_fach_w2.dta", replace

	* CAWI - pTarget (Welle 2)
	use "`dirneps'SC5_pTargetCAWI_R_4-0-0.dta", clear
	keep ID_t-tg51000 tg51300 tg51203 tg51311_g1R t291521
	keep if wave==2

	merge 1:1 ID_t using "Data\data_fach_w2.dta"
	keep if _merge==3
	drop _merge
	save "Data\data_fach_w2.dta", replace

	* weights (for waves 1 and 2)
	use "`dirneps'SC5_Weights_R_4-0-0.dta", clear
	keep ID_t w_t12_std
	merge 1:1 ID_t using "Data\data_fach_w2.dta"
	keep if _merge==3
	drop _merge

*** merge small but similar majors (as in census and his surveys)
	recode tg04001_g1R(-97=.), gen(B1ber1ab1)
	recode tg04004_g1R(-97 -95 -93 -54=.), gen(B1ber2ab1)

	* teachers *
	gen lehramt=.
	replace lehramt=1 if tg02001==1 | tg02001==2
	replace lehramt=0 if tg02001==3 | tg02001==4| tg02001==5| tg02001==6| tg02001==7| tg02001==8
	replace B1ber1ab1=80 if lehramt==1
	
	* cath. theology --> prot. theology
	recode B1ber1ab1(3=2)
	* philosophy --> history
	recode B1ber1ab1(4=5)
	* non-german philologies and cultural sciences --> cultural sciences
	recode B1ber1ab1(1 7 8 9 10 11 12 13=14)
	* special needs pedagogy --> pegagogy
	recode B1ber1ab1(17=16)
	* social and economic studies, political science --> social sciences
	recode B1ber1ab1(23 25=26)
	* mining and metallurgy --> geosciences
	recode B1ber1ab1(62=43)
	* urban and regional planning --> geography
	recode B1ber1ab1(67 57=44)
	* dentistry --> medical science
	recode B1ber1ab1(50=49)
	* forestry --> agronomy
	recode B1ber1ab1(59=58)
	* design --> architecture and interior design
	recode B1ber1ab1(76=66)
	* surveying and mapping, traffic engineering --> civil engineering
	recode B1ber1ab1 (65 69=68)
	* fine arts, performing arts, music, musicology --> art, art history
	recode B1ber1ab1(75 77 78=74)
	* industrial engineering(ing) --> industrial engineering(bwl)
	recode B1ber1ab1(70=31)
	label value B1ber1ab1 de2543ext1
	* "general engineering" does not exist in microcensus
	drop if B1ber1ab1==61

* define sample
gen sample=1
gen alter= 2011-t70000y
replace sample=0 if alter>25
recode t700001 (-97=.)(1=0)(2=1), gen(frau)
replace sample=0 if frau==.
replace sample=0 if tg51000!=1 	/*nur jene, die nicht abgebrochen haben */
drop if sample==0

* only fields with at least 100 observations
gen fsize=.
qui forvalues i=1/80 {
	count if B1ber1ab1==`i' & sample==1
	replace fsize = r(N) if B1ber1ab1==`i'
	}
	
**************
replace sample=0 if fsize<100
tab B1ber1ab1
keep if sample==1
**************

* generate math intensity index
tab B1ber1ab1, gen(fachdum)
global fachnr = r(r)
lab val fachdum1-fachdum$fachnr de2543ext1

recode t291521 (-97 -91=.)(1=0)(2=1)(3=2)(4=3),gen(mathint1)
gen mathint=mathint1/3

svyset ID_t[pw=w_t12_std]
qui forvalues i = 1/$fachnr {
	svy: mean mathint if (fachdum`i'==1 & sample==1)
		matrix fneps [`i', 2] = e(N)
		matrix fneps [`i', 3] = _b[mathint]
		matrix fneps [`i', 4] = _se[mathint]
	}

* reformat results	
matrix list fneps
svmat fneps
keep fneps*
drop if fneps1==.
lab var fneps1 "B1ber1ab1"
lab var fneps2 "obs_neps"
lab var fneps3 "mathint"
lab var fneps4 "mathint_se"
lab var fneps5 "diff_app_eltern_fm"
lab var fneps17 "diff_app_eltern_fm_se"
lab var fneps6 "diff_app_peers_fm"
lab var fneps18 "diff_app_peers_fm_se"
lab var fneps7 "app_eltern_f"
lab var fneps8 "app_eltern_f_se"
lab var fneps9 "app_eltern_m"
lab var fneps10 "app_eltern_m_se"
lab var fneps11 "propfemale_neps"
lab var fneps12 "propfemale_se"
lab var fneps13 "app_peers_f"
lab var fneps14 "app_peers_f_se"
lab var fneps15 "app_peers_m"
lab var fneps16 "app_peers_m_se"
lab var fneps19 "care"


* merge major characteristics created here with those created from census and his surveys
gen byte B1ber1ab1=fneps1 /* generate merge variable */
sort B1ber1ab1
save "Data\data_fach.dta", replace

use  "Data\fstats.dta", clear
gen byte B1ber1ab1=fstats1
sort B1ber1ab1
merge 1:1 B1ber1ab1 using "Data\data_fach.dta"
drop _merge
gen id_fach = _n

gen pfemale=		fstats3*100		/* 1 unit change=1 perc points 						*/
gen pfemale_se= 	fstats4*100
gen worklife=		fstats5*100		/* 1 index now varies between 0 and 100				*/
gen worklife_se=	fstats6*100
gen hrswork=		fstats7 		/* 1 unit change=1 hour more 						*/
gen hrswork_se=		fstats8
gen sdiscrim=		fstats9*100 	/* 1 unit change=1 perc points 						*/
gen sdiscrim_se=	fstats10*100
gen intercpt=		fstats11*100 	/* 1 unit change=1% wage more 						*/
gen intercpt_se=	fstats12*100
gen mathint=		fneps3*100 		/* 1 unit change=1 perc points 						*/
gen mathint_se= 	fneps4*100
gen apfmelt=		fneps5*100 		/* 1 unit change=1 perc points 						*/
gen apfmelt_se=		fneps17*100
gen apfmpeer=		fneps6*100		/* 1 unit change=1 perc points 						*/
gen apfmpeer_se=	fneps18*100
gen apfelt=			fneps7*100
gen apfelt_se=		fneps8*100
gen apmelt=			fneps9*100
gen apmelt_se=		fneps10*100
gen pfemale2=		fneps11*100		/* 1 unit change=1 perc points						*/
gen pfemale2_se=	fneps12*100
gen apfpeer=		fneps13*100
gen apfpeer_se=		fneps14*100
gen apmpeer=		fneps15*100
gen apmpeer_se=		fneps16*100

* code as care fields: psychology, pedagogy, social work, medical science, state teacher
gen care = 0
replace care =100 if (fstats1==15 | fstats1==16 | fstats1==27 | fstats1==49 | fstats1==80)

* compute standard deviations and standardized variables for later use in effects model
foreach var of varlist pfemale pfemale2 hrswork sdiscrim intercpt mathint apfmelt apfmpeer care {
	gen `var'_sd = .				/* compute estimated sd								*/ 
	summarize `var'
	replace `var'_sd = r(sd)
	gen `var'_std = `var' / `var'_sd
	}

* add variable labels
foreach var of varlist fstats4 fstats6 fstats8 fstats10 fstats12 fneps12 fneps14 fneps16 {
	lab var `var' "s.e."
	}

save "Data\data_fach.dta", replace
	
	
	
	
**********************************
*** individual characteristics ***
**********************************

*** create dataset from multiple panel waves 
	* pTarget (wave 1)
	use "`dirneps'SC5_pTargetCATI_R_4-0-0.dta", clear
	keep ID_t-inty tg04001_g1R tg04004_g1R tg02001 t700001 t70000y tg24150_g1 t66201a-t66208d t66207* t66210g
	keep if wave==1
	save "Data\data_ind.dta", replace

	* pTarget (wave 3)
	use "`dirneps'SC5_pTargetCATI_R_4-0-0.dta", clear
	keep ID_t wave t66210a-t66210p
	keep if wave==3
	merge 1:1 ID_t using "Data\data_ind.dta"
	keep if _merge==3
	drop _merge
	save "Data\data_ind.dta", replace

	* pTarget (wave 4 - for supplementary analysis only)
	use "`dirneps'SC5_pTargetCAWI_R_4-0-0.dta", clear
	keep ID_t wave t44630a t44613a
	keep if wave==4
	drop if ID_t==7015073		/* one weird observation with subspells */
	merge 1:1 ID_t using "Data\data_ind.dta"
	drop _merge
	save "Data\data_ind.dta", replace

	* school (wave 1)
	use "`dirneps'SC5_spSchool_R_4-0-0.dta", clear
	keep ID_t wave spell t724112 t724712 t724111 t724714 ts11209 ts11211 t724801 t724802 t724803 t724804 t724805 
	keep if wave==1
	by ID_t: gen maxspell= _N 	/* alle Informationen sind im letzten Spell */
	keep if spell==maxspell
	drop spell maxspell
	drop if ID_t==7015073 
	merge 1:1 ID_t using "Data\data_ind.dta"
	keep if _merge==3
	drop _merge
	order ID_t wave intd intm inty tg04001_g1R tg04004_g1R tg02001 t700001 t70000y  ts11209 ts11211 tg24150_g1
	save "Data\data_ind.dta", replace

	* weights (for waves 1 and 3)
	use "`dirneps'SC5_Weights_R_4-0-0.dta", clear
	keep ID_t w_t13_std
	drop if ID_t==7015073
	merge 1:1 ID_t using "Data\data_ind.dta"
	keep if _merge==3
	drop _merge

* gender
recode t700001 (-97=.)(1=0)(2=1), gen(frau)

* major
recode tg04001_g1R(-97=.), gen(B1ber1ab1)
recode tg04004_g1R(-97 -95 -93 -54=.), gen(B1ber2ab1)

* math grades vs german grades
gen math_punkte=-99
replace math_punkte=t724712 if t724712!=.
replace math_punkte=((-3*t724112)+17) if (t724112!=-20 & math_punkte==-99) 
replace math_punkte=. if (t724112==-98 | t724112==-97 | t724712==-98)
gen deut_punkte=-99
replace deut_punkte=t724714 if t724714!=.
replace deut_punkte=((-3*t724111)+17) if (t724111!=-20 & deut_punkte==-99) 
replace deut_punkte=. if (t724111==-98 | t724111==-97 | t724714==-98)
recode math_punkte deut_punkte (-1=0)(15.8 15.5=15)
gen dif_math_deut_pkt = (math_punkte - deut_punkte)

* RIASEC
recode t66207a_g1 t66207a_g1 t66207b_g1 t66207c_g1 t66207d_g1 t66207e_g1 t66207f_g1 (-55=.)
gen int_doer = (t66207a_g1 - 1)/4
gen int_thinker = (t66207b_g1 - 1)/4
gen int_creator = (t66207c_g1 - 1)/4
gen int_helper = (t66207d_g1 - 1)/4
gen int_persuader = (t66207e_g1 - 1)/4
gen int_organizer = (t66207f_g1 - 1)/4

* job values
numlabel de789, add
recode t66210a-t66210p (-98=.)
recode t44630a t44613a (-91 -97 -98=.)
gen flexi_index = (t66210d - 1)/5	
gen bread_index = (t66210h - 1)/5
gen bread_index2 = (t66210c - 1)/5
recode t44630a (4=0)(3=1)(2=2)(1=3)	/* "men and women should do same duties in household": recode so that it reflects DISagreement with the statement, i.e. reflects traditionalistic attitude */
gen bread_index3 = (t44630a - 1)/3	
gen bread_index4 = (t44613a - 1)/3  /* "it's a man's job to earn money and a woman's to look after children and household" */

*** merge small but similar majors
	* identify students on teacher track
	gen lehramt=.
	replace lehramt=1 if tg02001==1 | tg02001==2
	replace lehramt=0 if tg02001==3 | tg02001==4| tg02001==5| tg02001==6| tg02001==7| tg02001==8
	replace B1ber1ab1=80 if lehramt==1

	* cath. theology --> prot. theology
	recode B1ber1ab1(3=2)
	* philosophy --> history
	recode B1ber1ab1(4=5)
	* non-german philologies and cultural sciences --> cultural sciences
	recode B1ber1ab1(1 7 8 9 10 11 12 13=14)
	* special needs pedagogy --> pegagogy
	recode B1ber1ab1(17=16)
	* social and economic studies, political science --> social sciences
	recode B1ber1ab1(23 25=26)
	* mining and metallurgy --> geosciences
	recode B1ber1ab1(62=43)
	* urban and regional planning --> geography
	recode B1ber1ab1(67 57=44)
	* dentistry --> medical science
	recode B1ber1ab1(50=49)
	* forestry --> agronomy
	recode B1ber1ab1(59=58)
	* design --> architecture and interior design
	recode B1ber1ab1(76=66)
	* surveying and mapping, traffic engineering --> civil engineering
	recode B1ber1ab1 (65 69=68)
	* fine arts, performing arts, music, musicology --> art, art history
	recode B1ber1ab1(75 77 78=74)
	* industrial engineering(ing) --> industrial engineering(bwl)
	recode B1ber1ab1(70=31)
	label value B1ber1ab1 de2543ext1


*** define sample ***
gen alter= 2011-t70000y
drop if alter>25	/* persons older than 25 */
gen fullabi = 0
replace fullabi = 1 if ts11211==2 & ts11209==5
tab fullabi
keep if fullabi==1	/* persons with standard leaving certificate */
drop fullabi wave-tg24150_g1 alter

* drop persons from majors not in the choice set
gen keep=0
foreach num of numlist 5 14 15 16 26 27 28 30 31 37 38 39 40 42 44 49 58 63 64 66 68 74 80 {
	replace keep=1 if B1ber1ab1==`num'
	}
tab keep
keep if keep==1
drop keep

* listwise deletion
gen sample=0
egen miss = rowmiss (frau B1ber1ab1 dif_math_deut_pkt bread_index flexi_index int_doer int_thinker int_helper int_creator int_helper int_persuader int_organizer)
replace sample=1 if miss==0
tab sample

* supplementary analysis uses additional items and waves -> define separate sample.
gen sample_supl=0
egen miss_supl = rowmiss (frau B1ber1ab1 dif_math_deut_pkt bread_index bread_index2 bread_index3 bread_index4 flexi_index int_doer int_thinker int_helper int_creator int_helper int_persuader int_organizer)
replace sample_supl=1 if miss_supl==0
tab sample_supl

mat missatrand = J(13, 6, .)
mat colnames missatrand = mean_sample se_sample mean_drop se_drop diff wald
mat rownames missatrand = frau int_doer int_thinker int_creator int_helper int_persuader int_organizer dif_math_deut_pkt bread_index flexi_index

* listwise deletion: missing at random? 
svyset ID_t[pw=w_t13_std]
local counter = 0
foreach var of varlist frau int_doer int_thinker int_creator int_helper int_persuader int_organizer dif_math_deut_pkt bread_index flexi_index {
	
	local ++counter
	svy: mean `var', over(sample)
		mat MISS`counter' = r(table)
		mat missatrand [`counter', 1] = MISS`counter'[1,2]
		mat missatrand [`counter', 2] = MISS`counter'[2,2]
		mat missatrand [`counter', 3] = MISS`counter'[1,1]
		mat missatrand [`counter', 4] = MISS`counter'[2,1]
		mat missatrand [`counter', 5] = MISS`counter'[1,2] - MISS`counter'[1,1]
	test [`var']1 = [`var']0
		mat missatrand [`counter', 6] = r(p)
	}
mat list missatrand, format(%10.4f)
putexcel set "Output\indtable_miss.xlsx", replace
putexcel B2=matrix(missatrand, names) using "Output\indtable_miss.xlsx", replace 

keep if sample==1		
keep ID_t w_t13_std t66210d t66210h t66210c t66210n t66210l t66207* t66201a-bread_index4 sample sample_supl

* Compute standard deviations vor all variables for later use in semi-standardized effects model
svyset ID_t[pw=w_t13_std]
foreach var of varlist frau int_doer int_thinker int_creator int_helper int_persuader int_organizer dif_math_deut_pkt flexi_index bread_index bread_index2 bread_index3 bread_index4 {
	gen `var'_sd = .
	svy: mean `var'
	estat sd
	mat sd = r(sd)
	replace `var'_sd = sd[1,1]
	mat drop sd
	gen `var'_std = `var' / `var'_sd 					/* standardize variable against sd for later use in effects model */
	}

gen id_ind=_n
global indnr=_N
sort ID_t
save "Data\data_ind.dta", replace


*** create matched individual-major dataset ***
drop _all
set more off
local r=$fachnr*$indnr
set obs `r'
gen rownr=_n

gen id_ind=.
qui forvalues i = 1/$indnr {
	replace id_ind=`i' if rownr>(`i'-1)*$fachnr & rownr<=(`i'*$fachnr)
	}
bysort id_ind: gen id_fach=_n

* import information from the above two datasets
merge m:1 id_ind using "Data\data_ind.dta"
drop _merge
merge m:1 id_fach using "Data\data_fach.dta"
drop _merge

* generate dependent variable
gen choice=0
replace choice=1 if B1ber1ab1==fstats1

* generate interaction terms
foreach var of varlist pfemale-pfemale2 {
	gen `var'xfrau = `var'*frau
	}

rename dif_math_deut_pkt leist_md
rename dif_math_deut_pkt_std leist_md_std

gen intercptxbread = intercpt * bread_index
gen std_intercptxbread = intercpt_std * bread_index_std
gen intercptxbread2 = intercpt * bread_index2
gen std_intercptxbread2 = intercpt_std * bread_index2_std
gen intercptxbread3 = intercpt * bread_index3
gen std_intercptxbread3 = intercpt_std * bread_index3_std
gen intercptxbread3xfrau = intercpt * bread_index3 * frau
gen std_intercptxbread3xfrau = intercpt_std * bread_index3_std * frau
gen hrsworkxbread3 = hrswork * bread_index3
gen std_hrsworkxbread3 = hrswork_std * bread_index3_std
gen hrsworkxbread3xfrau = hrswork * bread_index3 * frau
gen std_hrsworkxbread3xfrau = hrswork_std * bread_index3_std * frau
gen intercptxbread4 = intercpt * bread_index4
gen std_intercptxbread4 = intercpt_std * bread_index4_std
gen intercptxbread4xfrau = intercpt * bread_index4 * frau
gen std_intercptxbread4xfrau = intercpt_std * bread_index4_std * frau
gen hrsworkxbread4 = hrswork * bread_index4
gen std_hrsworkxbread4 = hrswork_std * bread_index4_std
gen hrsworkxbread4xfrau = hrswork * bread_index4 * frau
gen std_hrsworkxbread4xfrau = hrswork_std * bread_index4_std * frau
gen mathintxleist_md = mathint * leist_md
gen std_mathintxleist_md = mathint_std * leist_md_std
gen hrsworkxflexi = hrswork * flexi_index
gen std_hrsworkxflexi = hrswork_std * flexi_index_std
gen std_apfmeltxfrau = apfmelt_std * frau_std
gen std_apfmpeerxfrau = apfmpeer_std * frau_std
gen std_sdiscrimxfrau = sdiscrim_std * frau_std
gen mathintxdoer = mathint * int_doer
gen std_mathintxdoer = mathint_std * int_doer_std
gen mathintxthinker = mathint * int_thinker
gen std_mathintxthinker = mathint_std * int_thinker_std
gen mathintxcreator = mathint * int_creator
gen std_mathintxcreator = mathint_std * int_creator_std
gen mathintxhelper = mathint * int_helper
gen std_mathintxhelper = mathint_std * int_helper_std
gen mathintxpersuader = mathint * int_persuader
gen std_mathintxpersuader = mathint_std * int_persuader_std
gen mathintxorganizer = mathint * int_organizer
gen std_mathintxorganizer = mathint_std * int_organizer_std
gen carexdoer = care * int_doer
gen std_carexdoer = care_std * int_doer_std
gen carexthinker = care * int_thinker
gen std_carexthinker = care_std * int_thinker_std
gen carexcreator = care * int_creator
gen std_carexcreator = care_std * int_creator_std
gen carexhelper = care * int_helper
gen std_carexhelper = care_std * int_helper_std
gen carexpersuader = care * int_persuader
gen std_carexpersuader = care_std * int_persuader_std
gen carexorganizer = care * int_organizer
gen std_carexorganizer = care_std * int_organizer_std

* generate major dummies for later use as FEs
tab id_fach, gen(fach)

* save dataset
order rownr id_ind ID_t id_fach frau choice
sort rownr id_ind id_fach
drop B1ber1ab1 rownr
compress
save "Data\data_choice_long.dta", replace

*** END ***	
log close
exit, clear
